#!/bin/sh

# 定义需要清理的文件
file_pattern="appinfo.ini"

# 检查是否有匹配的文件在暂存区
if git diff --cached --name-only | grep -E "$file_pattern" > /dev/null; then
    # 清理敏感信息
    git ls-files -z | grep -z -E "$file_pattern" | xargs -0 -I {} sh -c '
        sed -i "s/username=.*\$/username=/" "{}"
        sed -i "s/password=.*\$/password=/" "{}"
    '
fi

# 将修改后的文件重新添加到暂存区
git add $(git diff --cached --name-only)
